$(function(){
    $('[data-method]').append(function(){
        return "\n" 
        + "<form action='"+$(this).attr('href')+"' method='POST' style='display:none'>\n"
        + "<input type='hidden' name='_method' value='"+$(this).attr('data-method')+"'>\n"
        + "</form>\n";
    })
    .removeAttr('href')
    .attr('style','cursor:pointer;')
    .attr('onclick','confirm("Are you sure?") && $(this).find("form").submit();');
});
/*
$(function () {
    var makeRequest = function (method, target) {
        if(method === 'GET') {
            window.location.href = target;
            return;
        }
        var html = '<form accept-charset="UTF-8" action="'+target+'" method="POST">';
        html += '<input type="hidden" name="_method" value="'+method+'">';
        html += '</form>';
        console.log(html);
        $(html).submit();
    };

    $('a').on('click', function (ev) {
        var $a = $(this);
        if($a.data('method') === 'DELETE') {
            ev.preventDefault();
            ev.stopPropagation();
            var answer = confirm("Are you sure?");
            answer && makeRequest($a.data('method'), $a.attr('href'));
        }
    });
});
*/
